package com.hgw.Demo03_InterpreterPattern.examples;

/**
 * Data time:2021/12/17 19:39
 * StudentID:2019112118
 * Author:hgw
 * Description: 动作节点类，充当终结符表达式角色
 */
public class ActionNode extends AbstractNode{
    private String action;

    public ActionNode(String action) {
        this.action = action;
    }

    // 动作（移动方式）表达式的解释操作
    @Override
    public String interpret() {
        if (action.equalsIgnoreCase("move")) {
            return "移动";
        } else if (action.equalsIgnoreCase("run")) {
            return "快速移动";
        } else {
            return "无效指令";
        }
    }
}
